﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NFine.Service.SystemManage;
using NFine.Util;

namespace NFine.WebApi.Areas.SystemManage.Controllers
{
    [Route("api/SystemManage/[controller]")]
    [ApiController]
    public class TenantController : ControllerBase
    {
        private readonly TenantService _tenantService;
        public TenantController(TenantService tenantService)
        {
            _tenantService = tenantService;
        }

        // GET: api/SystemManage/Tenant
        [HttpGet()]
        public ContentResult Get([FromUri]Pagination pagination, string keyword)
        {
            var data = new
            {
                rows = _tenantService.GetList(pagination, keyword),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
    }
}
